package com.km.team.phsystem.service.impl;

import com.km.team.phsystem.beans.pojo.BusinessTypeOptArticle;
import com.km.team.phsystem.beans.pojo.BusinessTypeOptArticleExample;
import com.km.team.phsystem.dao.mybatis.BusinessTypeOptArticleMapper;
import com.km.team.phsystem.service.IBusiTypeArticleService;
import com.km.team.phsystem.service.impl.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Author: jiangjun
 * Date: 2019-01-19
 * Time: 15:57
 * Description:
 */
@Service("busiTypeArticleService")
public class BusiTypeArticleServiceImpl extends BaseService<BusiTypeArticleServiceImpl, BusinessTypeOptArticle>
        implements IBusiTypeArticleService {

    @Autowired
    private BusinessTypeOptArticleMapper mapper;

    @Override
    public int update(BusinessTypeOptArticle article) throws Exception {
        return baseUpdate(article);
    }

    @Override
    public BusinessTypeOptArticle getDataById(Integer id) throws Exception {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<BusinessTypeOptArticle> getTitleList() throws Exception {
        return mapper.selectByExample(null);
    }

    @Override
    public int delete(Integer id) throws Exception {
        BusinessTypeOptArticle article = baseGet(id);
        if(article == null){
            return 0;
        }
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<BusinessTypeOptArticle> getDataByBusiType(Integer busiType) throws Exception {
        if(busiType == null){
            return null;
        }
        BusinessTypeOptArticleExample example = new BusinessTypeOptArticleExample();
        example.or().andBusiTypeEqualTo(busiType.toString());
        return mapper.selectByExample(example);
    }
}
